package org.japo.java.basics.entities;

public class Nif {

    //Lista de letras
    public final static String LETRAS = "TRWAGMYFPDXBNJZSQVHLCKE";

    //Atibutos de la clase
    private int dni;
    private char letra;

    //Primer constructor
    public Nif() {
        this.letra = calcularLetraNif(dni);
    }

    //Segundo constructor
    public Nif(int dni) {
        this.dni = dni;
        this.letra = calcularLetraNif(dni);
    }

    public int getDni() {
        return dni;
    }

    public void setDni(int dni) {
        this.dni = dni;
    }

    public char getLetra() {
        return letra;
    }

    public static char calcularLetraNif(int dni) {
        return LETRAS.charAt(dni % 23);
    }

    public void mostrarNif() {
        System.out.printf(this.toString());//s de string, c caracter, d entero, f double
    }

    @Override
    public String toString() {
        return String.format("%08d%c\n", dni, letra); //To change body of generated methods, choose Tools | Templates.
    }
    
}

